#!/bin/sh /etc/rc.common
# Copyright (c) 2011-2017 OpenWrt.org

START=90

start(){
    config_load dogcom
    config_get version config version
    if [ "$version" == "dhcp" ]; then
        /usr/bin/dogcom -m dhcp -c /etc/dogcom.conf -d -e
        echo "Dogcom version dhcp has been started."
    else
        /usr/bin/dogcom -m pppoe -c /etc/dogcom.conf -d -e
        echo "Dogcom version pppoe has been started."
    fi
}

stop(){
    if [ ! -f "/tmp/dogcom.pid" ]; then
        echo "Dogcom is not running."
    else
        pid=`cat /tmp/dogcom.pid`
        kill $pid
        rm -f /tmp/dogcom.pid
        echo "Dogcom has been stopped."
    fi
}

restart(){
    stop
    sleep 1
    start
    echo "Dogcom has been restarted."
}
